import 'package:dio/dio.dart';
import 'package:get/get.dart';
import 'package:getx_app/app/constant/api.dart';
import 'package:getx_app/app/modules/home/models/shop_decoration.dart';

import 'state.dart';

class MainLogic extends GetxController {
  final MainState state = MainState();

  final dio = Get.find<Dio>();

  @override
  void onReady() {
    getShopDecoration();
  }

  Future<void> getShopDecoration() async {
    state.isLoading = true;
    final res = await dio.get("/h5/shop/decorate/fetch",
        queryParameters: {'shop_id': ApiConstant.SHOP_ID});
    final data = ShopDecoration.fromJson(res.data["data"]);
    state.shopDecoration = data;
    state.isLoading = false;
    update();
  }
}
